package com.sangeng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sangeng.constants.SystemConstants;
import com.sangeng.domain.ResponseResult;
import com.sangeng.domain.entity.Link;
import com.sangeng.domain.vo.LinkVo;
import com.sangeng.mapper.LinkMapper;
import com.sangeng.service.LinkService;
import com.sangeng.utils.BeanCopyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 友链(com.sangeng.domain.entity.Link)表服务实现类
 *
 * @author makejava
 * @since 2022-05-13 08:29:16
 */
@Service("LinkService")
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {
    @Autowired
    private LinkMapper linkMapper;

    @Override
    public ResponseResult getLinkList() {
        LambdaQueryWrapper<Link> linkLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //查询 link 状态为已审核 ，未删除状态
        linkLambdaQueryWrapper.eq(Link::getStatus, SystemConstants.ARTICLE_STATUS_NORMAL);
//        List<Link> links = linkMapper.selectList(linkLambdaQueryWrapper);
        List<Link> links = list(linkLambdaQueryWrapper);

        //封装为VO
        List<LinkVo> linkVos = BeanCopyUtils.copyBeanList(links, LinkVo.class);

        return ResponseResult.okResult(linkVos);
    }
}

